home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 January - Disc 2 / Macworld (1999-01) (Disk 2).dmg / Serious Demos / Symbolic Composer 4.2 / Environment / System / CRESC / Variations / select-eval < prev    next >
Lisp/Scheme  |  1997-02-02  |  737b  |  22 lines

  1. select-eval seed number list-of-variables             
  2.  
  3. This utility function selects a chosen <number> of variables  from a <list-of-variables> with a controlled random operation and evaluates each variable in order.
  4.  
  5. This can be used to great effect with temporary lists of note-lengths or symbols, effectively bypassing the need to create a library from which to pick material at random.
  6.  
  7. (setq r1 '(1/4 1/4)
  8.       r2 '(1/4 1/8 1/8)
  9.       r3 '(1/8 1/8 1/4)
  10.       r4 '(1/8 1/8 1/8 1/8)
  11.       r5 '(1/4. 1/8)
  12.       r6 '(1/8 1/4.)
  13.       r7 '(1/8 1/4 1/8)
  14.       r8 '(1/2)
  15. )
  16.  
  17. (setq rhythm-list '(r1 r2 r3 r4 r5 r6 r7 r8))
  18. (setq rhythms (select-eval 0.15 6 rhythm-list))
  19. --> (1/8 1/4. 1/4 1/4 1/4 1/8 1/8 1/4 1/4 1/4 1/4 1/8 1/8 1/8 1/8)
  20.  
  21.  
  22.